package com.roc.live.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.nfc.Tag;
import android.util.Log;

import com.roc.live.service.LiveIntentService;
import com.roc.live.service.LiveServiceCmd;
import com.roc.live.util.LiveUtil;

public class LiveReceiver extends BroadcastReceiver {

    private static final String Tag = LiveReceiver.class.getSimpleName();

    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        Log.d(Tag, "the code run in LiveReceiver, and the action is:" + action);
        boolean isRunning = LiveUtil.isServiceRunning(context, LiveIntentService.class.getName());
        if (isRunning) {
            Log.d(Tag, "the service is running!");
            LiveIntentService.startMyself(context, LiveServiceCmd.LIVE);
        } else {
            Log.d(Tag, "the service is not running!");
            LiveIntentService.startMyself(context, LiveServiceCmd.LIVE);
        }
    }
}
